<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <title>VUE学习 - 数据请求</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <!--载入vue.js-->
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>

<body>
    <div id="Application">
        使用Node.js写一个简单的api接口
        https://juejin.cn/post/6844903737522126861
        <br />

        您的名字是：{{data.name}} <br />
        您的ID是：{{data.id}}<br />
        您到请求方法是：{{data.age}}

    </div>
    <script>
        const app = Vue.createApp({
            setup() {
                const data = Vue.ref("");

                async function test1() {
                    let result = await axios({
                        url: 'http://localhost:3000/data',
                        method: 'GET',
                        params: {
                            list: '1'
                        }
                    })
                    console.log("成功了", result);
                    data.value = result.data;
                }
                test1();

                return { data };

            },
        })

        app.mount("#Application")
    </script>

</body>

</html>